<template>
	<view class="bottom-nav flex-col"
	:style="{'border-radius':isPriceDetail? '20rpx 20rpx 0rpx 0rpx':'0'}"
	>
		
		        <view class="price-detail" v-if="isPriceDetail" @tap="isPriceDetail=!isPriceDetail">
		        	<view class="text-km">
		        		全程 <text class="red-km">{{(distance / 1000).toFixed(2)}}km</text><text class="tips-km" >（起步价包含{{getArriveType?detailInfo.start_km:detailInfo.train_start_km}}km）</text>
		        	</view>
					<view class="detail-box flex-col justify-between">
						<view class="">
						{{getArriveType}}	起步价：<text class="red-price">{{getArriveType?detailInfo.star_price:detailInfo.train_start_price}}</text><text class="money-text"> 元</text>
						</view>
						<view class="">
							里程费：<text class="red-price">{{(parseInt(money) - parseInt(getArriveType?detailInfo.star_price:detailInfo.train_start_price)).toFixed(2)}}</text><text class="money-text"> 元</text>
						</view>
					</view>
		        </view>
		<view class="align-center justify-between">
			<view class="justify-start align-center">
				<!-- <template>
					<u-number-box v-model="value">
						<view slot="minus" class="minus">
							<u-icon name="minus" size="12" color="#FFF"></u-icon>
						</view>
						<text slot="input" style="" class="input">{{value}}</text>
						<view slot="plus" class="plus">
							<u-icon name="plus" color="#FFFFFF" size="12"></u-icon>
						</view>
					</u-number-box>
				</template> -->
				<view class=" " :class="loading?'justify-start':''">
					<text class="text_26">合计：</text>
					<view class="text_23" v-if="loading"><u-loading-icon size='16'></u-loading-icon></view>
					<text class="text_23" v-else >{{money}}元</text>
					<text v-if="isDetail" class="text_27" @tap="isPriceDetail=!isPriceDetail">价格明细</text>
				</view>
			
			</view>
			
			<view class="button_1 justify-center align-center" @click="onClick">
				{{btn}}
			</view>
		</view>
		
	</view>
</template>

<script>
	import {
		arriveType,
	
	} from '@/utils/constants.js'
	export default {
		name: "bottom-nav",
		props: {
			btn: {
				type: String,
				default: '去下单'
			},
			money: {
				type: String,
				default: '0'
			},
			detailInfo: {
				type: Object,
				default: ()=>{}
			},
			orderInfo: {
				type: Object,
				default: ()=>{
					return {
						split_type:'接机'
					}
				}
			},
			distance: {
				type: Number,
				default: 0
			},
			loading:{
				type: Boolean,
				default: true
			},
			isDetail:{
				type: Boolean,
				default: false
			},
		},
		data() {
			return {
				arriveType,
				isPriceDetail:false,
				
			};
		},
		computed: {
			getArriveType() {
				// <2表示接机送机 否则是接站送站
				return arriveType.find(item=>item.name == this.orderInfo.split_type).ind<2
			}
		},
		methods: {
			priceDetail(){
				this.isPriceDetail = true
			},
			onClick() {
				this.$emit('pay')
			}
		}
	}
</script>
<style>
	@import '/common/css/common.css';
</style>
<style lang="scss">
	.bottom-nav {
		left: 0;
		padding: 35rpx 40rpx;
		width: 100vw;
		bottom: 0;
		background: #FFF;
		z-index: 1;

		box-shadow: 0rpx -4rpx 10rpx 0rpx rgba(0, 0, 0, 0.1);
		position: fixed;
		padding-bottom: calc(30rpx + constant(safe-area-inset-bottom));
		padding-bottom: calc(30rpx + env(safe-area-inset-bottom));
		
		.price-detail{
			padding:13rpx 0 0;
			width: 100%;
			height: 230rpx;
			background: #FFFFFF;
			.detail-box{
				margin-top: 23rpx;
				width: 670rpx;
				height: 128rpx;
				background: #F8F8F8;
				border-radius: 5rpx 5rpx 5rpx 5rpx;
				padding: 21rpx 35rpx ;
				
				font-weight: 500;
				font-size: 26rpx;
				color: rgba(70,70,70,0.87);
				.red-price{
					font-weight: 500;
					font-size: 32rpx;
					color: #CC1D1D;
				}
				.money-text{
					color: rgba(0, 0, 0, 0.87);
				}
			}
			.text-km{
				font-weight: 500;
				font-size: 24rpx;
				color: rgba(0,0,0,0.87);
				.red-km{
					color: #CC1D1D;
					font-size: 30rpx;
				}
				.tips-km{
					color: rgba(42, 42, 42, 0.87);
				}
			}
		}

		.button_1 {
			width: 222rpx;
			height: 90rpx;
			background: #CC1D1D;
			border-radius: 10rpx 10rpx 10rpx 10rpx;
			font-family: Source Han Sans SC, Source Han Sans SC;
			font-weight: 400;
			font-size: 36rpx;
			color: #FFFFFF;
		}

		.text_23 {
			font-weight: 400;
			font-size: 40rpx;
			color: #000000;
		}

		.text_27 {
			font-size: 28rpx;
			color: #CC1D1D;
			margin-left: 16rpx;
			text-decoration: underline;
		}

		.text_26 {
			margin-left: 20rpx;
			font-family: Source Han Sans SC, Source Han Sans SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #000000;
		}
	}
</style>